package listTest.Could;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
//简单的爬虫
public class Test1 {
    public static void main(String[] args) {
    	basicSpider();
    }
    static void basicSpider() {
    	URL url=null;
    	InputStream is =null;
    	BufferedReader br =null;
    	StringBuilder sb = new StringBuilder();
    	String temp ="";
    	try {
			url = new URL("https://www.baidu.com");
			is = url.openStream();
			br=new BufferedReader(new InputStreamReader(is));
			while ((temp =br.readLine())!=null) {
				sb.append(temp);				
			}
			System.out.println(sb);
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally {
            try {
            	br.close();
             }catch (IOException e) {
            	 e.printStackTrace();
             }
            try {
            	is.close();
             }catch (IOException e) {
            	 e.printStackTrace();
             }
			
		}
    	
    	
    }

}
